package com.kaohe.domain;

import java.io.Serializable;
import java.util.List;
/*
 * 泛型
 * 	List<T> :你传递什么数据，list存储的就是什么
 * 
 * List<Product>	List<User>
 * 
 * PageBean<T>
 * PageBean<Product>
 * PageBean<User>
 * 
 */
public class PageBean<T> implements Serializable{
	
	private int pageNumber;//当前页
	private int pageSize;//每页的条数
	private int startIndex;//开始索引
	private int totalRecord;//总记录数
	private int totalPage;//总页数
	private List<T> result;//查询的数据
	
	//开始索引
	public int getStartIndex() {
		
		startIndex = (pageNumber- 1) * pageSize;
		
		return startIndex;
	}
	
	

	//总页数
	public int getTotalPage() {
		
		//总记录数据%每天条数
		if(totalRecord % pageSize == 0){
			
			totalPage = totalRecord / pageSize;
			
		}else{
			
			totalPage = totalRecord / pageSize +1;

		}
		return totalPage;
	}
	
	
	public int getPageNumber() {
		return pageNumber;
	}
	public void setPageNumber(int pageNumber) {
		this.pageNumber = pageNumber;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	
	public void setStartIndex(int startIndex) {
		this.startIndex = startIndex;
	}
	public int getTotalRecord() {
		return totalRecord;
	}
	public void setTotalRecord(int totalRecord) {
		this.totalRecord = totalRecord;
	}
	
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	public List<T> getResult() {
		return result;
	}
	public void setResult(List<T> result) {
		this.result = result;
	}
	public PageBean(int pageNumber,int startIndex,int pageSize,List<T> result) {
		super();
		this.pageNumber = pageNumber;
		this.startIndex = startIndex;
		this.pageSize = pageSize;
		this.result = result;
 	}
	
	public PageBean() {
		super();
 	}

	@Override
	public String toString() {
		return "PageBean [pageNumber=" + pageNumber + ", pageSize=" + pageSize + ", startIndex=" + startIndex
				+ ", totalRecord=" + totalRecord + ", totalPage=" + totalPage + ", result=" + result + "]";
	}
	
	 
	

}
